What do you suppose is the value of the arithmetic expression:

data[2] + data[6]

A good answer might be:

23; data[2] contains a 14 and data[6] contains a 9, the sum is 23.


Arithmetic Expressions

An expression such as data[3] is called a subscripted variable. A subscripted variable can be used anywhere an ordinary variable of the same type can be used. Since data[3] contains an int it can be used anywhere an int variable may be used.

An arithmetic expression can contain a mix of literals, variables, and subscripted variables. For example, if x contains a 10, then

(x + data[2]) / 4

evaluates to (10+14) / 4 == 6. Here are some other legal statements:

data[0] = (x + data[2]) / 4 ;

data[2] = data[2] + 1;

x = data[3]++ ;       // the data in slot 3 is incremented

data[4] = data[1] / data[6]

QUESTION 4:

Assume that the array holds values as in the picture. What will be the result of executing the statement:

data[0] = data[6] + 8;